import React,{Suspense} from "react";
import routers from './router/index'
import {Route,Routes,BrowserRouter,Navigate} from 'react-router-dom'
const App = () => {
const rendRoutes=(arr:any)=>{
    return arr&&arr.map((item:any,index:number)=>{
        return <Route key={index} path={item.path}
        element={item.element?<item.element></item.element>:<Navigate to={item.to}></Navigate>}
        >
        {
            item.children&&rendRoutes(item.children)
        }
        </Route>
    })
}
return (
    <Suspense fallback={<div>加载中....</div>}>
        <BrowserRouter>
            <Routes>
                {
                    rendRoutes(routers)
                }
            </Routes>
        </BrowserRouter>

    </Suspense>
  )
}
export default App
